//
//  FuJinLastPicCollectionViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/3/6.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "FuJinLastPicCollectionViewCell.h"

@implementation FuJinLastPicCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imagePic = [[UIImageView alloc] init];
        [self.contentView addSubview:_imagePic];
        [_imagePic release];
    }
    return self;
}


- (void)setDic:(NSDictionary *)dic{
    if (_dic != dic) {
        [_dic release];
        _dic = [dic retain];
        
    }
    
    NSString *image = _dic[@"photo_s"];
    
    [_imagePic sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:PLACE_HLODER]];
    
    
    _dic = dic;
    NSLog(@"111111%@", dic[@"photo_s"]);
    [_imagePic sd_setImageWithURL:[NSURL URLWithString:dic[@"photo_s"]]];
    
    if ([_dic[@"photo_info"] isEqual:[NSNull null]]) {
      
    }else{
        //获取图片的真实高度
        NSDictionary *ph_info = _dic[@"photo_info"];
       
        CGFloat height = [ph_info[@"h"] floatValue];
        CGFloat width = [ph_info[@"w"] floatValue];
        //把图片的高度固定为130
        CGFloat scale = height / 130;
        //图片的宽度为
        CGFloat realWidth = width / scale;
        
        _imagePic.frame = CGRectMake(0, 0, realWidth, 130);
    }

    
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
}


- (void)dealloc{
    [_dic release];
    [_imagePic release];
    [super dealloc];
}

@end
